import Router from 'koa-router'

const { courseIdExist } = require('../middleware/course.middleware')
const { auth } = require('../middleware/auth.middleware')
const { getCourse, getCourseByname, getById, addCourse, updateCourse, deleteCourse } = require('../controller/course.controller') 
const router = new Router({ prefix: '/course' })

/**
 * 课程管理模块
 * @description course_video
 */
router.get('/get', getCourse) // 获取所有课程(分页可选)
router.get('/search/name', getCourseByname)  // 根据课程名或教师名获取课程(分页可选)
router.get('/search/:id', courseIdExist, getById) // 根据id获取课程
router.post('/add', auth, addCourse) // 添加课程
router.put('/update/:id', auth, courseIdExist, updateCourse) // 更新课程
router.delete('/delete/:id', auth, courseIdExist, deleteCourse) // 删除课程

module.exports = router